﻿using System;
using QLNet;
using p = FinPlusAnalytics.QLConvParser;
using u = FinPlusUtility.Utility;

namespace FinPlusAnalytics
{
    public class ForwardRateAgreementTrade : Trade
    {
        public string Id { get; private set; }

        //construct
        public ForwardRateAgreementTrade(string marketName, string cacheName, string id, string curveName, double nominal, DateTime start, DateTime maturity,
            double fixedRate, string payRec, string index, bool endOfMonth = false)
        {
            Id = id;
            var market = Markets.Instance.GetMarket(marketName);
            var cache = Caches.Instance.GetCache(cacheName);
            var curve = market.GetLinkedCurve(curveName);
            var indx = market.GetIndex(index);
            var type = u.EnumParse<QLNet.Position.Type>(p.LongShort(payRec));

            Underlying = new ForwardRateAgreement(start, maturity, type, fixedRate, nominal, indx, curve);

            cache.Add(id, this, curveName);
        }
    }
}
